package net.csdn.business.mirror.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.csdn.business.mirror.entity.bean.GithubToken;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GithubTokenMapper extends BaseMapper<GithubToken> {
    @Select("<script> select token FROM github_token </script>")
    List<GithubToken> getAllToken();

    @Delete("delete from github_token")
    int clearData();

    @Insert("<script> " +
            "INSERT INTO github_token (token) VALUES " +
            "<foreach item='item' index='index' collection='tokens' open='(' separator='), (' close=')'> " +
            "#{item}" +
            "</foreach>" +
            "</script>")
    int insertTokens(@Param("tokens") List<String> tokens);
}
